<template>
	<!-- 举报列表页 -->
	<view class="page">
		<view class="main-content" v-for="(tem,index) in rlist" :key="index">
			<view class="main-head">
				<view class="head-left">
					<template v-if="tem.flag == 0">
						<text style="color: red;">未处理</text>
						<text>|</text>
					</template>
					<text>{{tem.typename}}</text>
					<text>|</text>
					<text>{{tem.jbr}}</text>
					<text>|</text>
					<text>{{tem.lxdh}}</text>
				</view>
				<view class="head-right" @click="deldata(tem.id)">
					<image src="@/static/img/del.png"></image>
				</view>
			</view>
			<view class="main-bottom">
				{{tem.memo}}
			</view>
		</view>
		<view style="text-align: center;font-size: 30upx;padding: 20upx 0;">不要扯了，没有数据了！</view>
		
		<!-- 删除弹框 -->
		<uni-popup :show="isshowdel" position="middle" mode="fixed">
			<view class="popup-view">
				<view class="popup-third">您确定要删除吗？删除后无法恢复！</view>
				<view class="popup-button">
					<view @click="get_order(0)"><strong>取消</strong></view>
					<view @click="get_order(1)"><strong>确定</strong></view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
import { toast,router } from '@/common/util.js';
import { secondreportList,secondDelreport } from '@/service/getData.js';
import { mapState, mapActions } from 'vuex';

export default {
	onPullDownRefresh() {
		this.getreport('DownRefresh');
	},
	computed: {
		...mapState(['dictionaryTempData','userInfo'])
	},
	data() {
		return {
			rlist:[],
			isshowdel: false,
			delid: '',
		};
	},
	onLoad(){
		this.getreport();
	},
	methods: {
		getreport(type) {
			let sent={"type":"jubaolist","uid":this.userInfo.uid,"jbid":"0"};
			toast.loading();
			console.log("数据传出："+JSON.stringify(sent))
			secondreportList({data:sent}).then(res => {
				toast.hideLoading();
				if (type == 'DownRefresh') {
				    uni.stopPullDownRefresh();
				}
				console.log(res.data);
				var arr = eval('('+res.data+')');
				if(arr[0].stat == "1"){
					this.rlist = arr[0].meslist;
				}
			})
		},
		deldata(id){
			this.delid = id;
			this.isshowdel = true;
		},
		// 确定删除
		get_order(num) {
			if(num == 1){
				let sent={"type":"deljubao","jbid":this.delid};
				toast.loading();
				secondDelreport({data:sent}).then(res => {
					toast.hideLoading();
					console.log(res);
					var arr = eval('('+res.data+')');
					if(arr[0].stat == "1"){
						toast.show("删除成功！")
						this.getreport('init');
					}
				});
				this.getreport();
			}
			this.isshowdel = false;
		} ,
		onNavigationBarButtonTap() { // 标题栏刷新按钮点击事件
			router.navigateTo('/pages/common/report/report')
		},
	}
};
</script>

<style lang="scss">
@import '@/style/page/card.scss';
@import '@/style/page/form.scss';
@import '@/style/page/foot.scss';
.page{
	padding: 0;
	margin: 0;
	background-color: #ffffff;
	.main-content{
		padding: 20upx;
		border-bottom: 1upx solid #e3e3e3;
		.main-head{
			flex-direction: row;
			display: flex;
			.head-left{
				color: #848484;
				text{
					padding-right: 10upx;
					font-size: 28upx;
				}
			}
			.head-right{
				position: absolute;
				right: 20upx;
				image{
					width: 40upx;
					height: 40upx;
				}
			}
		}
		.main-bottom{
			color: #848484;
			font-size: 28upx;
			padding: 10upx 0;
		}
	}
	.popup-view{
		display: flex;
		flex-direction: column;
		background-color: #fff;
		width: 240px;
		text-align: center;
		padding-top: 20upx;
		.popup-third{
			font-size: 33upx;
			color: #000000;
		}
		.popup-button{
			display: flex;
			flex-direction: row;
			margin-top: 30upx;
			padding: 10upx 20upx 20upx 20upx;
			color: #007AFF;
			view:nth-child(1){
				position: absolute;
				right: 190upx;
				font-size: 33upx;
			}
			view:nth-child(2){
				position: absolute;
				right: 80upx;
				font-size: 33upx;
			}
		}
	}
}
</style>
